/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package ufpr.ees.suhck.dao.usuario;

import java.util.List;
import org.hibernate.Query;
import ufpr.ees.suhck.dao.GenericDaoImpl;
import ufpr.ees.suhck.db.HibernateUtil;
import ufpr.ees.suhck.model.Gerente;

/**
 *
 * @author Mera
 */
public class GerenteDaoImpl extends GenericDaoImpl<Gerente, Long> implements GerenteDao {

    
    public Gerente findPorEmail(String email) {
        sf = HibernateUtil.getSessionFactory().openSession();
        Query query = sf.getNamedQuery(Gerente.FIND_POR_EMAIL);
        query.setParameter("email", email);
        List<Gerente> gerente = query.list();
        sf.close();
        if (gerente.size() > 0) {
            return gerente.get(0);
        }
        return null;
    }
}
